import store from '../store'
(function(global, factory) {
    "use strict";
    if (typeof exports === "object" && typeof module !== undefined) {
        module.exports = factory();
    } else if (typeof define === "function" && define.amd) {
        define(factory);
    } else {
        window.RongIM = factory();
    }
})(window, function() {
    var RongIMLib,
        RongIMClient,
        appKey,
        token,
        token2,
        connectToken,
        targetIdList = [],
        targetId = "user9",  // 接受者默认 id
        targetId2 = "user10",  // 接收者默认值 id
        recallMessage = null,
        clearMessage,
        mockVoice = getMockVoice();

    var modules;

    var UploadUrl = 'http://upload.qiniu.com';
    
    //加入聊天室后，可以用任意一个发送消息的方法发送消息，只需要conversationType为CHATROOM
    var chatRoomId = "chatRoomId-008"; // 聊天室 Id,可任意指定，能区分不同聊天室即可

    var publicServiceId = "Rong_shuise";

    function markMessage(message) {
        recallMessage = message;
        clearMessage = message;
    }

    function init(params, callbacks, modulesConf) {
        params = params || {};
        modules = modulesConf || {};
        var navi = params.navi || "",
            api = params.api || "",
            imClient = params.imClient,
            protobuf = modules.protobuf || null,
            dataProvider = null,
            config = {},
            imInstance = null;

        // 存储到全局
        appKey = params.appKey;
        token = params.token;
        // token2 = params.token2;
        connectToken = params.connectToken;
        RongIMLib = modules.RongIMLib || {};
        RongIMClient = RongIMLib.RongIMClient;
		console.log(RongIMClient)
        targetIdList = params.targetIds || [];
        if (targetIdList.length > 0) {
            targetId = targetIdList[0];
        }
        if (targetIdList.length > 1) {
            targetId2 = targetIdList[1];
        }

        // 私有云切换navi导航，私有云格式 '120.92.10.214:8888'
        if (navi !== "") {
            config.navi = navi;
        }

        // 私有云切换api,私有云格式 '172.20.210.38:81:8888'
        if (api !== "") {
            config.api = api;
        }

        // support protobuf url + function
        if (protobuf !== null) {
            config.protobuf = protobuf;
        }

        // 引入桌面版 C++ SDK
        if (imClient) {
            dataProvider = new RongIMLib.VCDataProvider(imClient);
        }

        RongIMLib.RongIMClient.init(appKey, dataProvider, config);

        imInstance = RongIMClient.getInstance();

        /*
            设置连接状态监听器
         */
        RongIMClient.setConnectionStatusListener({
            onChanged: function(status) {
                switch(status) {
                    case RongIMLib.ConnectionStatus["CONNECTED"]:
                    case 0:
                        console.log("连接成功")
                        callbacks.getInstance && callbacks.getInstance(imInstance);
                        break;

                    case RongIMLib.ConnectionStatus["CONNECTING"]:
                    case 1:
                        console.log("连接中")
                        break;

                    case RongIMLib.ConnectionStatus["DISCONNECTED"]:
                    case 2:
                        console.log("当前用户主动断开链接")
                        break;

                    case RongIMLib.ConnectionStatus["NETWORK_UNAVAILABLE"]:
                    case 3:
                        console.log("网络不可用")
						Status.reconnect(function(res){
							console.log(res)
						})
                        break;

                    case RongIMLib.ConnectionStatus["CONNECTION_CLOSED"]:
                    case 4:
                        console.log("未知原因，连接关闭")
						Status.reconnect(function(res){
							console.log(res)
						})
                        break;

                    case RongIMLib.ConnectionStatus["KICKED_OFFLINE_BY_OTHER_CLIENT"]:
                    case 6:
                        console.log("用户账户在其他设备登录，本机会被踢掉线")
                        break;

                    case RongIMLib.ConnectionStatus["DOMAIN_INCORRECT"]:
                    case 12:
                        console.log("当前运行域名错误，请检查安全域名配置")
                        break;
                }
            }
        });

        /*
            文档：http://www.rongcloud.cn/docs/web.html#3、设置消息监听器

            注意事项：
                1：为了看到接收效果，需要另外一个用户向本用户发消息
                2：判断会话唯一性 ：conversationType + targetId
                3：显示消息在页面前，需要判断是否属于当前会话，避免消息错乱。
                4：消息体属性说明可参考：http://rongcloud.cn/docs/api/js/index.html
        */
        RongIMClient.setOnReceiveMessageListener({
            // 接收到的消息
            onReceived: function (message) {
                // 判断消息类型
                console.log("新消息: " + message.targetId);
                console.log(message);
				store.commit("newMsg",message);
                callbacks.receiveNewMessage && callbacks.receiveNewMessage(message);
            }
        });

        /*
            开始链接
        */
        RongIMClient.connect(connectToken, {
            onSuccess: function(userId) {
                RongIMClient.Conversation.watch(function (list) {
                  console.log('已成功获取会话列表', list);
                });
                callbacks.getCurrentUser && callbacks.getCurrentUser({userId:userId});
            },
            onTokenIncorrect: function() {
                console.log("token无效");
            },
            onError:function(errorCode){
                console.log(errorCode);
            }
        }, params.userId);
    };

    var Status = {
        changeUser: function(callbacks,token1) {
            RongIMClient.getInstance().logout();
            connectToken = connectToken === token ? token2 : token;
            let params = {
                appKey: appKey,
                token: token1,
                token2: "",
                targetIds: "",
                connectToken: token1
            };
            
            init(params, callbacks, modules);
        },

        /*
           断开连接 
         */
        disconnect: function(callback) {
            /*
            文档：http://www.rongcloud.cn/docs/api/js/RongIMClient.html
            */
            RongIMClient.getInstance().disconnect();
            callback(null, '断开连接 成功');
        },

        /*
            重新连接
         */
        reconnect: function(callback) {
            /*
            1: reconnect 是重新连接，并没有重连机制，调用此方法前应该进行网络嗅探，网络正常再调用 reconnect。
            2: 提示其他设备登录请勿调用重连方法。
            3: docs   http://www.rongcloud.cn/docs/api/js/RongIMClient.html
            */
            RongIMClient.connect(token, {
                onSuccess: function(userId) {
                    callback(null, '重新链接成功, 用户 id: ' + userId)
                },
                onTokenIncorrect: function() {
                    callback('重新链接失败, token 无效');
                },
                onError:function(errorCode){
                    var info = '';
                    switch (errorCode) {
                        case RongIMLib.ErrorCode.TIMEOUT:
                            info = '超时';
                            break;
                        case RongIMLib.ErrorCode.UNKNOWN_ERROR:
                            info = '未知错误';
                            break;
                        case RongIMLib.ErrorCode.UNACCEPTABLE_PROTOCOL_VERSION:
                            info = '不可接受的协议版本';
                            break;
                        case RongIMLib.ErrorCode.IDENTIFIER_REJECTED:
                            info = 'appkey不正确';
                            break;
                        case RongIMLib.ErrorCode.SERVER_UNAVAILABLE:
                            info = '服务器不可用';
                            break;
                  }
                  callback("重新链接 失败, " + info);
                }
            });
        },

        /*
            设置自己在线状态
         */
        setUserStatus: function(callback) {
            /*
                自定义在线状态(举例)：
                
                1、在线
                    status : 10 

                2、离开
                    status : 11 

                3、忙碌
                    status : 12  

            */
            var status = 10;
            RongIMClient.getInstance().setUserStatus(status, {
                onSuccess: function(status) {
                    callback(null, '设置在线状态成功: ' + status);
                },
                onError: callback
            });
        },

        /*
            查询其他人在线状态
         */
        getUserStatus: function() {
            var params =  {
                userIds: targetIdList
            };
            RongIMClient.getInstance().setUserStatusListener(params, function(userStatus) {
                callback(null, '获取用户在线状态成功' + JSON.stringify(userStatus));
            });
        }
    };

    var Message = {
        /*
            文字消息
         */
        sendText: function(callback,id,content,type) {
            /*
            文档： http://www.rongcloud.cn/docs/web.html#5_1、发送消息
                   http://rongcloud.cn/docs/api/js/TextMessage.html
            1: 单条消息整体不得大于128K
            2: conversationType 类型是 number，targetId 类型是 string
            */
            /*
                1、不要多端登陆，保证所有端都离线
                2、接收 push 设备设置:
                    （1）打开系统通知提醒
                    （2）小米设置 “授权管理” －> “自己的应用” 为自启动
                    （3）应用内不要屏蔽新消息通知
                3、内置消息类型，默认 push，自定义消息类型需要
                   pushData 显示逻辑顺序：自定义 > 默认
                4、发送其他消息类型与发送 TextMessage 逻辑、方式一致
            */
            var msg = new RongIMLib.TextMessage({ content: content, extra: type });
            var conversationType = parseInt(RongIMLib.ConversationType.PRIVATE);
            var targetId = id.toString();  // 目标 Id
            console.log(conversationType)
			console.log(targetId)
            RongIMClient.getInstance().sendMessage(conversationType, targetId, msg, {
              onSuccess: function (message) {
                // message 为发送的消息对象并且包含服务器返回的消息唯一 id 和发送消息时间戳
                console.log('发送文本消息成功', message);
				callback(null, message);
              },
              onError: function (errorCode) {
                console.log('发送文本消息失败', errorCode);
				callback(errorCode, message);
              }
            });
        },

        /*
            图片消息
         */
        sendImage: function(callback, url, base64) {
            /*
            文档：http://www.rongcloud.cn/docs/api/js/ImageMessage.html

            需自行解决文件上传
            上传插件（含获取缩略图方法）: https://github.com/rongcloud/rongcloud-web-im-upload
            
            缩略图必须是base64码的jpg图，而且不带前缀"data:image/jpeg;base64,"，不得超过100K
            压缩：https://github.com/rongcloud/rongcloud-web-im-upload/blob/master/resize.html
            */
            var content = {
                imageUri: url || "http://rongcloud.cn/images/newVersion/log_wx.png", 
                content: base64 || getBase64Image()
            };

            var msg = new RongIMLib.ImageMessage(content);

            var conversationType = RongIMLib.ConversationType.PRIVATE;

            RongIMClient.getInstance().sendMessage(conversationType, targetId, msg, {
                onSuccess: function(message) {
                    markMessage(message);
                    callback(null, message);
                },
                onError: callback
            }); 
        },
        
        /*
            文件消息
         */
        sendFile: function(callback) {
            /*
            文档：http://www.rongcloud.cn/docs/api/js/ImageMessage.html

            upload组件：https://github.com/rongcloud/rongcloud-web-im-upload
            上传插件文档: http://rongcloud.cn/docs/web.html#上传插件

            单条消息整体不得大于128K

            文件消息分两步：
                1、上传文件至文件服务器
                2、发送文件信息和文件 URL
            */
            var content = {
                name: "log_wx", // 文件名称
                size: "20k", // 文件大小，单位自己约定
                type: "png", // 文件的后缀名，例如 png、js、doc ...
                fileUrl: "http://rongcloud.cn/images/newVersion/log_wx.png" // 文件地址
            };

            var msg = new RongIMLib.FileMessage(content);

            var conversationType = RongIMLib.ConversationType.PRIVATE;

            RongIMClient.getInstance().sendMessage(conversationType, targetId, msg, {
                onSuccess: function(message) {
                    markMessage(message);
                    callback(null, message);
                },
                onError: callback
            });
        },

        /*
            音频消息
         */
        sendVoice: function(callback) {
            /*
            文档：http://www.rongcloud.cn/docs/api/js/VoiceMessage.html

            需自行解决录音和转码问题，要求编码为base64格式amr，不带前缀，不得超过100K

            声音播放：https://rongcloud.github.io/websdk-demo/voice.html
            */
            var content = {
                content: mockVoice,
                duration : 20
            };

            var msg = new RongIMLib.VoiceMessage(content);

            var conversationType = RongIMLib.ConversationType.PRIVATE;

            RongIMClient.getInstance().sendMessage(conversationType, targetId, msg, {
                onSuccess: function(message) {
                    markMessage(message);
                    callback(null, message);
                },
                onError: callback
            });
        },

        /*
            @ 消息
         */
        sendAt: function(callback) {
            /*
            @ 消息对象
            全部：RongIMLib.MentionedType.ALL；
            部分：RongIMLib.MentionedType.PART
            
            文档说明：http://support.rongcloud.cn/kb/NjE1
            接收@代码：https://rongcloud.github.io/websdk-demo/connect-check.html
            */
            var mentioneds = new RongIMLib.MentionedInfo();
            mentioneds.type = RongIMLib.MentionedType.PART;
            mentioneds.userIdList = [targetId, targetId2];

            var content = {
                content: "This is a at message!",
                extra: "extra info",
                mentionedInfo: mentioneds
            };

            var msg = new RongIMLib.TextMessage(content);

            var conversationType = RongIMLib.ConversationType.PRIVATE;

            RongIMClient.getInstance().sendMessage(conversationType, targetId, msg, {
                onSuccess: function(message) {
                    markMessage(message);
                    callback(null, message);
                },
                onError: callback
            }, true);
        },

        /*
            位置消息
         */
        sendLocation: function(callback,position) {
            /*
            文档：http://www.rongcloud.cn/docs/api/js/LocationMessage.html

            缩略图必须是base64码的jpg图，而且不带前缀"data:image/jpeg;base64,"，不得超过100K

            需要自己做显示效果，一般显示逻辑：图片加链接，传入经纬度并跳转进入地图网站
            */
            var content = {
                "content":getBase64Image(),
                "latitude":"24.114",
                "longitude":"334.221",
                "poi":"北京市朝阳区北苑路北辰泰岳大厦"
            };

            var msg = new RongIMLib.LocationMessage(content);

            var conversationType = RongIMLib.ConversationType.PRIVATE;

            RongIMClient.getInstance().sendMessage(conversationType, targetId, msg, {
                onSuccess: function(message) {
                    markMessage(message);
                    callback(null, message);
                },
                onError: callback
            });
        },

        /*
            富文本消息
         */
        sendRichContent: function(callback) {
            /*
            文档: http://www.rongcloud.cn/docs/api/js/RichContentMessage.html
            */ 
            var content = {
                "title": "sendRichContentMessage",
                "content": "<a href=\"http://www.rongcloud.cn\">hello</a>",
                "imageUri": "http://www.demo.com/1.jpg",
                "url": "http://www.rongcloud.cn/",
                "extra": "{\"key\":\"value\"}"
            };

            var msg = new RongIMLib.RichContentMessage(content);

            var conversationType = RongIMLib.ConversationType.PRIVATE;

            RongIMClient.getInstance().sendMessage(conversationType, targetId, msg, {
                onSuccess: function(message) {
                    markMessage(message);
                    callback(null, message);
                },
                onError: callback
            });
        },
		//消除未读消息
		clearRed:function(callback,msgid,lasttiem,uid){
			var messageUId = msgid;  // 消息唯一 Id, message 中的 messageUid
			var lastMessageSendTime = lasttiem;  // 最后一条消息的发送时间
			var type = '1';  // 备用，默认赋值 1 即可
			// 以上 3 个属性在会话的最后一条消息中可以获得
			
			var msg = new RongIMLib.ReadReceiptMessage({ messageUId: messageUId, lastMessageSendTime: lastMessageSendTime, type: type });
			var conversationType = RongIMLib.ConversationType.PRIVATE;
			var targetId = uid;  // 目标 Id
			
			RongIMClient.getInstance().sendMessage(conversationType, targetId, msg, {
			  onSuccess: function (message) {
			    console.log('发送已读通知成功', message);
			  },
			  onError: function (errorCode) {
			    console.log('发送已读通知失败', errorCode);
			  }
			});
		},

        /*
            自定义消息
         */
        sendRegister: function(callback) {
            /*
            文档：http://www.rongcloud.cn/docs/web_api_demo.html#自定义消息

            注意事项：
                1：init之前注册新消息类型
                2：对应接收 onReceived: function (message) {}
                    message.messageType == "PersonMessage"
                3：需要自己做解析实现
            */
            var propertys = ["name","age","gender"]; // 消息类中的属性名。
            registerMessage("PersonMessage",propertys);

            var content = {
                name: {
                    first: "Bob",
                    last: "Smith"
                },
                age: 3,
                gender: "male"
            };

            var msg = new RongIMClient.RegisterMessage.PersonMessage(content);

            var conversationType = RongIMLib.ConversationType.PRIVATE;

            RongIMClient.getInstance().sendMessage(conversationType, targetId, msg, {
                onSuccess: function(message) {
                    markMessage(message);
                    callback(null, message);
                },
                onError: callback
            });
        },

        /*
            撤回消息
         */
        sendRecall: function(callback) {
            if (recallMessage == null) {
                console.log('请先发送任意一条消息再执行撤回');
                callback('请先发送任意一条消息再执行撤回');
                return;
            }
            /*
            注意事项:
                消息撤回服务器端没有时间限制，由客户端决定
             */
            RongIMClient.getInstance().sendRecallMessage(recallMessage, {
                onSuccess: function(message) {
                    callback(null, message);
                },
                onError: callback
            })
        },

        /*
            同步状态消息
         */
        sendSyncReadStatus: function(callback,sendtime,uid) {
            /*
            具体处理说明文档： http://support.rongcloud.cn/kb/NjE0
            一端发送，其他端接受并做同步更新
            */ 
            var sentTime = sendtime;

            var content = {
                lastMessageSendTime: sentTime
            };

            var msg = new RongIMLib.SyncReadStatusMessage(content);

            var conversationType = RongIMLib.ConversationType.PRIVATE;

            RongIMClient.getInstance().sendMessage(conversationType, uid, msg, {
                onSuccess: function(message) {
                    callback(null, message);
                },
                onError: callback
            });
        },

        /*
            检查是否有未读消息
         */
        checkUnread: function(callback) {
            /*
            文档: http://www.rongcloud.cn/docs/web.html#unread_message

            此接口必须在init()方法之后调用，但不依赖于connect
            只返回true/false，不返回具体的未读数量
            若连接成功后调用此方法将一直返回 false。
            */
            RongIMClient.getInstance().hasRemoteUnreadMessages(token, {
                onSuccess: function(hasMessage) {
                    callback(null, {
                        hasMessage: hasMessage,
                        tip: '此接口必须在init()方法之后调用，但不依赖于connect. 只返回true/false. 不返回具体的未读数量. 若连接成功后调用此方法将一直返回 false'
                    });
                },
                onError: callback
            });
        },

        /*
            消息接收
         */
        receive: function(callback) {
            callback(null, '请见 init 方法里的 RongIMClient.setOnReceiveMessageListener');
        },

        /*
            获取历史消息列表
         */
        getHistory: function(callback,id,num) {
            /*
            文档：http://www.rongcloud.cn/docs/web_api_demo.html#获取历史消息

            注意事项：
                1：一定一定一定要先开通 历史消息云存储 功能，本服务收费，测试环境可免费开通
                2：登录开发者后台可以直接开启 https://developer.rongcloud.cn/app
                2：timestrap第二次拉取必须为null才能实现循环拉取
            */
			if(num==10){
			    var timestamp = 0;  //0, 1483950413013
			}else{
			   var timestamp = null;  //0, 1483950413013
			}
            var count = num;  // 2 <= count <= 20
           

            var conversationType = RongIMLib.ConversationType.PRIVATE;
			console.log("dsjkndjkdjkdjjdjdjdjd")
            RongIMClient.getInstance().getHistoryMessages(conversationType, id, timestamp, count, {
                onSuccess: function(list, hasMsg) {
                    //可通过sort订制其他顺序
					console.log(list)
                    list.sort(function(a, b) {
                        return a.sentTime < b.sentTime;
                    });
                    callback(null, list);
                },
                onError: function(err){
					
				}
            })
        },

        /*
            清除历史消息
         */
        clearHistory: function(callback) {
            /*
                文档：http://www.rongcloud.cn/docs/web_api_demo.html#会话接口

                注意事项：必须开通历史消息云存储

                参数说明：
                timestamp 取值范围:  timestamp >=0 并且 timestamp <= 当前会话最后一条消息的 sentTime
            */
            if (!clearMessage) {
                return callback('请先发一条消息');
            }
            var params = {
                conversationType: clearMessage.conversationType,
                targetId: clearMessage.targetId,
                timestamp: clearMessage.sentTime
            };
            RongIMClient.getInstance().clearRemoteHistoryMessages(params, {
                onSuccess: function() {
                    callback('清除历史消息成功');
                },
                onError: function(err) {
                    err = '请排查: 历史消息云存储是否开通, ' + err;
                    callback(err);
                }
            })
        }
    };

    var Conversation = {
        /*
            获取会话列表
         */
        getList: function(callback) {
            /*
            文档：http://www.rongcloud.cn/docs/web_api_demo.html#会话接口
                http://www.rongcloud.cn/docs/web.html#5_2、同步会话列表
                http://www.rongcloud.cn/docs/api/js/Conversation.html

            历史消息云存储开通位置：https://developer.rongcloud.cn/service/roam/rXxI4IAJjxRAD72SpQ==

            注意事项：
                1：一定一定一定要先开通 历史消息云存储 功能，本服务收费，测试环境可免费开通
                2：只有发过消息才能生成会话
            */
            
            var conversationTypes = null; //具体格式设置需要补充
            var limit = 150; //获取会话的数量，不传或传null为全部，暂不支持分页
            RongIMClient.getInstance().getConversationList({
                onSuccess: function(list) {
					console.log('获取会话列表成功', list);
                    callback(null, list);
                },
                onError: function(error) {
                    console.log('获取会话列表失败', error);
                }
            }, conversationTypes);
        },

        /*
            获取会话
         */
        getDetail: function(callback,id) {
            /*
            注意:
                需在 getConversationList 方法执行之后执行，否则返回null
             */

            var conversationType = RongIMLib.ConversationType.PRIVATE;
            RongIMClient.getInstance().getConversation(conversationType, id, {
                onSuccess: function(result) {
                    callback(null, result);
                },
                onError: callback
            });
        },

        /*
            获取会话未读数
         */
        getUnreadCount: function(callback) {
            /*
                阅读时间戳缓存在 localStorage 中，消息状态根据发送时间和阅读时间戳对比判断
                每次接受新消息后通过重新调用此方法计算
            */

            var conversationType = RongIMLib.ConversationType.PRIVATE;
            RongIMClient.getInstance().getUnreadCount(conversationType, targetId, {
                onSuccess: function(count){
                   callback(null, count);
                },
                onError: callback
            });
        },

        /*
            获取总未读数
         */
        getTotalUnreadCount: function(callback) {
            /*
                阅读时间戳缓存在 localStorage 中，消息状态根据发送时间和阅读时间戳对比判断
                每次接受新消息后通过重新调用此方法计算
             */
            RongIMClient.getInstance().getTotalUnreadCount({
                onSuccess: function(count) {
                    callback(null, count);
                },
                onError: callback
            });
        },

        /*
            清除未读数
         */
        clearUnreadCount: function(callback,uid) {
            /*
                此方法清除当前端的未读数，并不会多端同步，
                多端同步需要发送 SyncReadStatusMessage：http://support.rongcloud.cn/kb/NjE0
             */
            // conversationType
            var conversationType = RongIMLib.ConversationType.PRIVATE;
            RongIMClient.getInstance().clearUnreadCount(conversationType, uid, {
                onSuccess: function() {
                    callback(null, '清除未读数成功');
                },
                onError: callback
            });
        },

        /*
            清除总未读数
         */
        clearTotalUnreadCount: function(callback) {
            RongIMClient.getInstance().clearTotalUnreadCount({
                onSuccess: function() {
                    callback(null, '清除总未读数成功');
                },
                onError: callback
            });
        },

        /*
            删除会话
         */
        remove: function(callback,tId) {
			console.log('remove'+tId)
            var conversationType = RongIMLib.ConversationType.PRIVATE;
            RongIMClient.getInstance().removeConversation(conversationType, tId, {
                onSuccess: function() {
					console.log('成功')
                    callback(null, '删除会话成功');
                },
                onError: callback
            });
        },

        /*
            删除所有会话
         */
        clear: function(callback) {
            RongIMClient.getInstance().clearConversations({
                onSuccess: function() {
                    callback(null, '清除会话成功');
                },
                onError: callback
            });
        },
		delMsg:function(callback,msgs,uid){
			var conversationType = RongIMLib.ConversationType.PRIVATE;
			console.log(uid)
			console.log(conversationType)
			console.log("conversationType " + typeof conversationType)
			console.log("targetId " + typeof uid)
			RongIMClient.getInstance().deleteRemoteMessages(conversationType, uid, msgs, {
			  onSuccess: callback,
			  onError: function(error) {
			    console.log('清除失败', error);
			  }
			});
		}
    };

    var Chatroom = {
        /*
            加入聊天室
         */
        enter: function(callback) {
            /*
            文档: http://www.rongcloud.cn/docs/web_api_demo.html#聊天室

            聊天室不支持通过 getHistoryMessages 方法获取历史消息，

            count：//拉取最近的会话内容（最多50条），-1不拉取 
            */

            RongIMClient.getInstance().joinChatRoom(chatRoomId, 10, {
                onSuccess: function() {
                    callback(null, '加入聊天室成功');
                },
                onError: callback
            });
        },

        /*
            聊天室发消息
         */
        sendTextMessage: function(callback) {
            var content = {
                content: "hello，time：" + new Date().getTime(),
                extra:"RongCloud"
            };

            var conversationType = RongIMLib.ConversationType.CHATROOM;
            var msg = new RongIMLib.TextMessage(content);

            RongIMClient.getInstance().sendMessage(conversationType, chatRoomId, msg, {
                onSuccess: function(message) {
                    callback(null, message);
                },
                onError: callback
            });
        },

        /*
            聊天室发题目
         */
        sendQAMessage: function(callback) {
            /*
            文档：http://www.rongcloud.cn/docs/web_api_demo.html#自定义消息

            注意事项：
                1：init之前注册新消息类型
                2：对应接收 onReceived: function (message) {}
                    message.messageType == "PersonMessage"
                3：需要自己做解析实现
            */
            var propertys = ["title","submitAPI","questions"]; // 消息类中的属性名。
            registerMessage("QA", propertys);

            var questions = [
                {
                    id: 8560,
                    question : "中国首都是那个城市？",
                    answers : [{ id: 9901,answer: '上海', bingo: 9904},
                               { id: 9903,answer: '武汉', bingo: 9904 },
                               { id: 9904,answer: '北京', bingo: 9904 },
                               { id: 9905,answer: '深圳', bingo: 9904 }]
                },
                {
                    id: 8561,
                    question : "世界上最大的岛是那个？",
                    answers : [{ id: 9906,answer: '马达加斯加', bingo: 9909},
                               { id: 9907,answer: '海南', bingo: 9909 },
                               { id: 9908,answer: '台湾', bingo: 9909 },
                               { id: 9909,answer: '格陵兰', bingo: 9909 }]
                },
                {
                    id: 8562,
                    question : "冰与火之歌里，那个家族的徽章是狼？",
                    answers : [{ id: 9910,answer: '史塔克', bingo: 9910  },
                               { id: 9911,answer: '塔格利安', bingo: 9910 },
                               { id: 9912,answer: '兰尼斯特', bingo: 9910 }]
                },
                {
                    id: 8563,
                    question : "地球上最大的哺乳动物是？",
                    answers : [{ id: 9913,answer: '鲸鱼', bingo: 9913 },
                               { id: 9914,answer: '大象', bingo: 9913 },
                               { id: 9915,answer: '巨蟒', bingo: 9913 },
                               { id: 9916,answer: '恐龙', bingo: 9913 }]
                },
                {
                    id: 8564,
                    question : "人们常说的花季是几岁？",
                    answers : [{ id: 9917,answer: 15, bingo: 9920 },
                               { id: 9918,answer: 20, bingo: 9920 },
                               { id: 9919,answer: 18, bingo: 9920 },
                               { id: 9920,answer: 16, bingo: 9920 }]
                },
                {
                    id: 8565,
                    question : "成龙、林志颖、郭德纲最年轻的是谁？",
                    answers : [{ id: 9921,answer: '成龙' , bingo: 9921},
                               { id: 9922,answer: '林志颖', bingo: 9921 },
                               { id: 9923,answer: '郭德纲', bingo: 9921 }]
                },
                {
                    id: 8565,
                    question : "劳动法规定，劳动者试用期不能超过几个月？",
                    answers : [{ id: 9921,answer: 3 , bingo: 9921},
                               { id: 9922,answer: 6, bingo: 9921 },
                               { id: 9923,answer: 9, bingo: 9921 },
                               { id: 9924,answer: 12, bingo: 9921 }]
                },
                {
                    id: 8566,
                    question : "融云成立几年了？",
                    answers : [{ id: 9921,answer: 4 , bingo: 9921},
                               { id: 9922,answer: 5, bingo: 9921 },
                               { id: 9923,answer: 3, bingo: 9921 },
                               { id: 9924,answer: 2, bingo: 9921 }]
                },
                {
                    id: 8567,
                    question : "变脸是我国哪个戏剧的绝活？",
                    answers : [{ id: 9921,answer: '川剧' , bingo: 9921},
                               { id: 9922,answer: '京剧', bingo: 9921 },
                               { id: 9923,answer: '豫剧', bingo: 9921 },
                               { id: 9924,answer: '评剧', bingo: 9921 }]
                }
            ];

            var qIndex = Math.floor(Math.random()*5);

            var content = {
                title: "冲顶大会",
                submitAPI: "http://abc.com/check",
                questions: JSON.stringify([questions[qIndex]])
            };

            var msg = new RongIMClient.RegisterMessage.QA(content);

            var conversationType = RongIMLib.ConversationType.CHATROOM;
            RongIMClient.getInstance().sendMessage(conversationType, chatRoomId, msg, {
                onSuccess: function(message) {
                    callback(null, message)
                },
                onError: callback
            });
        },

        /*
            退出聊天室
         */
        quit: function(callback) {
            RongIMClient.getInstance().quitChatRoom(chatRoomId, {
                onSuccess: function() {
                    callback(null, '退出聊天室成功');
                },
                onError: callback
            });
        },

        /*
            获取聊天室信息
         */
        getInfo: function(callback) {
            /*
            需确认 当前用户 已加入聊天室
            */ 
            var order = RongIMLib.GetChatRoomType.REVERSE;// 排序方式。
            var memberCount = 10; // 获取聊天室人数 （范围 0-20 ）

            RongIMClient.getInstance().getChatRoomInfo(chatRoomId, memberCount, order, {
                onSuccess: function(chatRoom) {
                    callback(null, chatRoom);
                },
                onError: callback
            });
        }
    };



    /*
    公众号
    RongIMLib.ConversationType = {
        APP_PUBLIC_SERVICE : "应用服务平台 mc",
        PUBLIC_SERVICE : "公众服务平台 mp"
    };
    */
    var Public = {
        /*
            获取已关注公众号
         */
        getList: function(callback) {
            /* 
            getRemotePublicServiceList = function (mpId, conversationType, pullMessageTime, callback)  
            */ 
            RongIMClient.getInstance().getPublicServiceList({
                onSuccess: function(list) {
                    callback(null, list);
                },
                onError: callback
            });
        },

        /*
            查找公众号
         */
        search: function(callback) {
            /*
            WebAPI文档：http://www.rongcloud.cn/docs/api/js/RongIMClient.html
            iOS文档：http://www.rongcloud.cn/docs/ios_imlib.html#公众服务
            */ 
           
            var searchType = 1; //[0-exact 1-fuzzy]  文档: http://www.rongcloud.cn/docs/api/js/global.html#SearchType
            var keywords = "Rong";
            RongIMClient.getInstance().searchPublicService(searchType, keywords, {
                onSuccess:function(list){
                    callback(null, list);
                },
                onError: callback
            });
        },

        /*
            订阅公众号
         */
        subscribe: function(callback) {
            /*
            http://www.rongcloud.cn/docs/api/js/RongIMClient.html

            */

            var publicServiceType = RongIMLib.ConversationType.APP_PUBLIC_SERVICE; //固定值
            RongIMClient.getInstance().subscribePublicService(publicServiceType, publicServiceId, {
                onSuccess: function(list) {
                    callback(null, list);
                },
                onError: callback
            });
        },

        /*
            取消订阅公众号
         */
        unsubscribe: function(callback) {
            /*
            http://www.rongcloud.cn/docs/api/js/RongIMClient.html

            */

            var publicServiceType = RongIMLib.ConversationType.APP_PUBLIC_SERVICE; //固定值
            RongIMClient.getInstance().unsubscribePublicService(publicServiceType, publicServiceId, {
                onSuccess: function(list){
                    callback(null, list);
                },
                onError: callback
            });
        },

        /*
            获取公众号详情
         */
        getProfile: function(callback) {
            /*
            http://www.rongcloud.cn/docs/api/js/RongIMClient.html

            必须是已经关注的公众号，才能获取到详情
            */

            var publicServiceType = RongIMLib.ConversationType.APP_PUBLIC_SERVICE; //固定值
            RongIMClient.getInstance().getPublicServiceProfile(publicServiceType, publicServiceId, {
                onSuccess:function(profile){
                    callback(null, profile);
                }, 
                onError: callback
            });
        },

        /*
            用户给公众号发消息
         */
        sendMessage: function(callback) {
            /*
            文档： http://www.rongcloud.cn/docs/web.html#5_1、发送消息
                   http://rongcloud.cn/docs/api/js/TextMessage.html
            1: 单条消息整体不得大于128K
            2: conversationType 类型是 number，targetId 类型是 string
            */
            var content = {
                content: "公众号你好"
            };

            var msg = new RongIMLib.TextMessage(content);

            var publicServiceType = RongIMLib.ConversationType.APP_PUBLIC_SERVICE; //固定值
            RongIMClient.getInstance().sendMessage(publicServiceType, publicServiceId, msg, {
                onSuccess: function (message) {
                    callback(null, message);
                },
                onError: callback
            });
        }
    };

    var Upload = {
        UploadUrl: UploadUrl,
        getFileToken: function(fileType, callback) {
            RongIMClient.getInstance().getFileToken(fileType, {
                onSuccess: function(result) {
                    var token = result.token;
                    callback(null, token);
                },
                onError: callback
            });
        },
        getFileUrl: function(fileType, hash, callback) {
            RongIMClient.getInstance().getFileUrl(fileType, hash, null, {
                onSuccess: function(result) {
                    var downloadUrl = result.downloadUrl;
                    callback(null, downloadUrl);
                },
                onError: callback
            });
        }
    };

    function registerMessage(type, propertys) {
        var messageName = type; // 消息名称。
        var objectName = "s:" + type;  // 消息内置名称，请按照此格式命名 *:* 。
        var mesasgeTag = new RongIMLib.MessageTag(true,true); //true true 保存且计数，false false 不保存不计数。

        RongIMClient.registerMessageType(messageName, objectName, mesasgeTag, propertys);
    }

    //获取base64假数据方法
    function getBase64Image(){
        return "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wAARCABkAGQDASIAAhEBAxEB/8QAGwABAAMBAQEBAAAAAAAAAAAAAAMEBQIGAQn/xAAwEAABAwMCBQMCBQUAAAAAAAAAAQIDBAUREiEGEzFBURRhgXGRFSMysdEiM1Kh8P/EABsBAQACAwEBAAAAAAAAAAAAAAADBQEEBgIH/8QALxEAAgIBAwMBBwIHAAAAAAAAAQIAAxEEEiEFBjFRExQiQWFxgQdCIzIzUrGywf/aAAwDAQACEQMRAD8A/Ko2uH3NhpLjUrDHI6KNrmo9uUzuYpucOypBR3KZY2SaI2rpemUXrsp3n6aEDuWlmbbhLjnGcYosOcfPHnH0mrrP6J/H+RI28Szak12yhc3uiRKir/s+cR0cEFXDJTQ8r1EaPWNE6L9C/Z7xRVdSlPLbqSnld/akbGmNXZP+UrxNrH8URMubkdI1+y4w3CIqtx7H0TWUHrvQaaLtb7571qKqksFQUads/FuJw+XVuFxtIBOciain2VpIXbtBJGfMqs4auzmI7ksarkyjHPRHL8FOG3Vk9WtCyFUmTOWOXGMfUludTUrdZ5nSPSRkrkaucK3C7YPR4zxHRyvajZJKXU9PfClF0zs/t7uHWHTaJbqxTqKqX3Orb0scpuGEXY4Izt+IYP05lfUW0rubByCftj88iYbeGru6LmJTtRcZ0K9Ed9ijT0dTV1HpYIXOl3y3pjHXPgu2ypnkv8UzpHK+SbDlz1Rexpwq6F9+mgykrHKjVTqiZXOCDp/afb/X1p1OiFtda2WpYGZXZlqpN25MIoVmCldp3AEg5PMy99tRKtgnAx+TiZz+GLw1WokDXavD02+p1ZaGm5VR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EYrmLKZK104LKEG/h/gkjHJJqBstjV1TZIMVQ9GLFMqoh7AF92qdC8033bD5l75l+0+LGkQwh/AKdND1quXzewahKPVHtraLJCjGB/hBKt5CriqQDfu/EaqXQkeLFafrh7AOeT3KJ/ACkwhOrSbpYQsLJBHzB/ga8tJoefCznqPEOPxVBIiLE+GoB5gHdj8eJH6CbpHCxkVddquLE8rGB7ALuCisqE67liVp78DB4t0LGmF6JdgpJuRGznAFm6YNK+8XN6cLE4kwh9kFmQZX5mqCCW2hqUTyK1KLHKYdh9gVzGZ7m+ttHopsTtVOlMG";
    }

    return {
        init: init,
        Status: Status,
        Message: Message,
        Conversation: Conversation,
        Chatroom: Chatroom,
        Public: Public,
        Upload: Upload
    };
});
